package controller;
import java.awt.Point;
import view.Canvas;
import view.Designer;
import model.Prescription;
import model.PrescriptionBox;import model.PrescriptionLabel;/** * An event handler class for the right click menu on the canvas * @author Daniel Bond, Mohammed Abdullah, Gideon Pyzer * */
public class RightClickMenuEventHandler extends EventHandler {		/**	 * Creates the appropriate event from a message passed to this method	 * @param the event object with the message needed to identify the behaviour required.	 */
	public void createEvent(CustomEvent event) {
		Prescription prescription = Prescription.getInstance();
		Designer designer = Designer.getInstance();		Canvas canvas = Canvas.getInstance();
		if (event.getName().equals("AddBox")){
			designer.switchLists(false);
			Point point = (Point) event.getAttached();
			int x = (int) point.getX();
			int y = (int) point.getY();
			prescription.addObject(new PrescriptionBox(), x, y);
			designer.update();			canvas.repaint();			return;			//TODO: need to add right click functionality for labels to be added!
		}		if(event.getName().equals("AddLabel")){			designer.switchLists(false);			Point point = (Point) event.getAttached();			int x = (int) point.getX();			int y = (int) point.getY();			prescription.addObject(new PrescriptionLabel(), x, y);			designer.update();			canvas.repaint();			return;		}		
		if (event.getName().equals("objectDelete")){
			prescription.removeObject(prescription.getSelectedIndex());			canvas.repaint();			return;
		}		
		if (event.getName().equals("backgroundColour")){
			designer.switchLists(false);
			prescription.changeBGColour();
			designer.update();			canvas.repaint();			return;
		}		
		if (event.getName().equals("objectLineColour")){
			prescription.changeLineColour();			canvas.repaint();			return;
		}		
		if (event.getName().equals("objectFillColour")){
			prescription.changeFillColour(prescription.getSelectedIndex());			canvas.repaint();			return;
		}
		if (event.getName().equals("objectTextColour")){
			prescription.changeTextColour();			canvas.repaint();			return;
		}
		if (event.getName().equals("objectTransparent")){
			prescription.transparent();			canvas.repaint();			return;
		}
		if (event.getName().equals("objectSendToBack")){
			prescription.sendToBack(prescription.getSelectedIndex());			canvas.repaint();			return;
		}
		if (event.getName().equals("objectBringToFront")){
			prescription.bringToFront(prescription.getSelectedIndex());			canvas.repaint();			return;
		}
	}
}